package com.unknowpupil.web.component.wallet.factory;

import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;

/**
 * @Classname: Web3jFactory
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2019/10/19 0:41
 * @Description:
 * @Version: 1.0
 */
public class Web3jFactory {
    /**
     *  节点地址 ，Web3j对智能合约的调用 不用自己配置节点
     */

    private static String ip = "https://mainnet.infura.io/v3/70b25cf11fbb46f4858c3e83b03054f6";
    private Web3jFactory(){}
    private volatile static Web3j web3j;
    public static Web3j build(){
        if(web3j==null){
            synchronized (Web3jFactory.class){
                //双重锁机制，以求绝对单例
                if(web3j==null){
                    web3j = Web3j.build(new HttpService(ip));
                }
            }
        }
        return web3j;
    }
}
